; Music of Nether Earth (1987) (Icon Design Ltd.)
; Ripped by Megachur the 28/06/2009

	write "NETHEREA.BIN"

music_date_rip	equ &1c69
music_adr	equ &7bc5-1
first_theme	equ 0
last_theme	equ 0	; 0 -> 0

	read "music_header_v1_0.asm"

;
.init_music
;
	xor a
	ld (l8108),a
	ld (l8109),a
	ld hl,l810a
	ld ix,l7c0f
	ld bc,&0020	;	ld c,#20 modified by Megachur (b must be = 0 !!!)
	xor a
	ld (l7f3b),a
	ld a,#03
.l7bdb
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	push hl
	ld (ix+#10),#01
	ld (ix+#00),b
	ld (ix+#1d),b
	ld (ix+#03),e
	ld (ix+#04),d
	ex de,hl
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld (ix+#05),#02
	ld (ix+#06),b
	pop hl
	ld (ix+#01),e
	ld (ix+#02),d
	add ix,bc
	dec a
	jr nz,l7bdb
	inc a
	ld (l7c6f),a
	ld (l8108),a
	ret
.l7c0f
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#09
.l7c2f
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#12
.l7c4f
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#24
.l7c6f
	db #00
;
.play_music
;
	ld hl,l8107
	dec (hl)
	jr nz,l7c79
	ld (hl),#10
	ret
.l7c79
	ld a,(l8108)
	and a
	jp z,l7cd2
.l7c81 equ $ + 1
	ld a,#00
	ld (l7cce),a
	ld hl,l7c6f
	dec (hl)
	jr nz,l7ca6
	ld b,(hl)
	ld ix,l7c0f
	call l7e48
	ld ix,l7c2f
	call l7e48
	ld ix,l7c4f
	call l7e48
	ld hl,l7c6f
.l7ca5 equ $ + 1
	ld (hl),#01
.l7ca6
	ld ix,l7c0f
	call l7eef
	ld (l7ffe),hl
	ld (l8006),a
	ld ix,l7c2f
	call l7eef
	ld (l8000),hl
	ld (l8007),a
	ld ix,l7c4f
	call l7eef
	ld (l8002),hl
	ld (l8008),a
.l7cce equ $ + 1
	ld a,#00
	ld (l8004),a
.l7cd2
	ld a,(l8109)
	and a
	jr z,l7d08
	ld hl,(l800b)
	ld (l7ffe),hl
	ld hl,(l800f)
	ld (l8002),hl
	ld a,(l8011)
	ld (l8004),a
	ld a,(l8005)
	or #2d
	ld hl,l8012
	and (hl)
.l7cf5 equ $ + 2
	ld (l8005),a
	ld a,(l8013)
	ld (l8006),a
	ld a,(l8015)
	ld (l8008),a
	ld a,(l8017)
	ld (l800a),a
.l7d08
	ld a,(l8108)
	ld hl,l8109
	or (hl)
	jr nz,l7d27
	ret
;
.stop_music
;
	xor a
	ld (l8108),a
	ld (l8109),a
	call l7d4d
	xor a
	ld (l8006),a
	ld (l8007),a
	ld (l8008),a
	ret
.l7d27
	ld hl,l800a
	ld d,#0c
.l7d2c
	ld e,(hl)
	ld b,#f4
	out (c),d
	ld bc,#f600
	out (c),c
	ld a,#c0
	out (c),a
	out (c),c
	ld b,#f4
	out (c),e
	ld b,#f6
	add a
	out (c),a
	out (c),c
	dec hl
	dec d
	jp p,l7d2c
	ret
.l7d4d
	ld de,#0d00	; #d000 modified by Megachur
.l7d50
	call l7d5a
	dec e
	jp p,l7d50
	ld de,#073f
.l7d5a
	ld b,#f4
	out (c),d
	ld bc,#f600
	out (c),c
	ld a,#c0
	out (c),a
	out (c),c
	ld b,#f4
	out (c),e
	ld b,#f6
	add a
	out (c),a
	out (c),c
	ret
	db #ca,#b2,#b6,#bb,#79,#a8,#a3,#10
	db #92,#8a,#4f,#39,#61,#b7,#01
	xor a
	ld (l8108),a
	pop hl
	jp l7d4d
	ld c,(ix+#05)
	ld b,(ix+#06)
	ld l,(ix+#03)
	ld h,(ix+#04)
	add hl,bc
	inc bc
	inc bc
	ld a,(hl)
	inc hl
	ld d,(hl)
	ld e,a
	or d
	jr nz,l7dae
	ld l,(ix+#03)
	ld h,(ix+#04)
	ld bc,#0002
	ld e,(hl)
	inc hl
	ld d,(hl)
.l7dae
	ld (ix+#05),c
	ld (ix+#06),b
	ld b,#00
	jp l7e56
	ld a,(ix+#1f)
	ld c,a
	and #07
	ld hl,l7fe3
	xor (hl)
	and c
	xor (hl)
	ld (hl),a
	ld a,#01
	ld (ix+#1e),a
	jp l7e56
	ld a,(ix+#1f)
	ld c,a
	and #38
	ld hl,l7fe3
	xor (hl)
	and c
	xor (hl)
	ld (hl),a
	xor a
	ld (ix+#1e),a
	jp l7e56
	ld hl,l7fe3
	ld a,(ix+#1f)
	cpl
	and (hl)
	ld (hl),a
	ld a,#01
	ld (ix+#1e),a
	jr l7e56
	ld a,(de)
	inc de
	ld (ix+#07),b
	ld (ix+#08),b
	ld (ix+#0d),a
	set 2,(ix+#00)
	ld a,(de)
	ld (ix+#0e),a
	inc de
	jr l7e56
	ld a,(de)
	inc de
	ld (l7f3b),a
	jr l7e56
	ld a,(de)
	ld (ix+#1b),a
	inc de
	ld a,(de)
	ld (ix+#1a),a
	inc de
	ld (ix+#1c),a
	jr l7e56
	set 7,(ix+#00)
	set 3,(ix+#00)
	jr l7e56
	ld (ix+#1d),b
	jr l7e56
	ld (ix+#1d),#40
	jr l7e56
	ld (ix+#1d),#c0
	jr l7e56
	set 1,(ix+#00)
	jr l7e56
	ld (ix+#13),b
	res 5,(ix+#00)
	jr l7e82
.l7e48
	dec (ix+#10)
	jr nz,l7e8f
	ld (ix+#00),b
	ld e,(ix+#01)
	ld d,(ix+#02)
.l7e56
	ld a,(de)
	inc de
	and a
	jp m,l7ea0
	ld (ix+#12),a
	bit 0,(ix+#1e)
	jr z,l7e68
	ld (l7c81),a
.l7e68
	ld a,(ix+#19)
	ld (ix+#13),a
	set 5,(ix+#00)
	set 6,(ix+#00)
	ld a,(ix+#14)
	ld (ix+#16),a
	ld a,(ix+#17)
	ld (ix+#18),a
.l7e82
	ld a,(ix+#11)
	ld (ix+#10),a
	ld (ix+#02),d
	ld (ix+#01),e
	ret
.l7e8f
	ld a,(ix+#00)
	bit 3,a
	ret z
	rla
	jr nc,l7e9c
	inc (ix+#12)
	ret
.l7e9c
	dec (ix+#12)
	ret
.l7ea0
	cp #b8
	jr c,l7ee7
	add #20
	jr c,l7ecc
	add #10
	jr c,l7ed2
	add #10
	jr nc,l7ec5
	ld c,a
	ld hl,l80c0
	add hl,bc
	ld c,(hl)
	add hl,bc
	ld (ix+#0b),l
	ld (ix+#09),l
	ld (ix+#0c),h
	ld (ix+#0a),h
	jr l7e56
.l7ec5
	add #09
	ld (l7ca5),a
	jr l7e56
.l7ecc
	inc a
	ld (ix+#11),a
	jr l7e56
.l7ed2
	ld (ix+#19),a
	ld a,(de)
	inc de
	ld (ix+#14),a
	ld a,(de)
	inc de
	ld (ix+#15),a
	ld a,(de)
	inc de
	ld (ix+#17),a
	jp l7e56
.l7ee7
	ld hl,l7cf5
	ld c,a
	add hl,bc
	ld c,(hl)
	add hl,bc
	jp (hl)
.l7eef
	ld c,(ix+#00)
	bit 5,c
	jr z,l7f3a
	ld a,(ix+#16)
	sub #10
	jr nc,l7f22
	bit 6,c
	jr z,l7f27
	add (ix+#13)
	jr nc,l7f07
	sbc a
.l7f07
	add #10
	ld (ix+#13),a
	ld a,(ix+#18)
	sub #10
	jr nc,l7f1d
	res 6,c
	ld a,(ix+#15)
	ld (ix+#16),a
	jr l7f3a
.l7f1d
	ld (ix+#18),a
	jr l7f3a
.l7f22
	ld (ix+#16),a
	jr l7f3a
.l7f27
	cpl
	sub #0f
	add (ix+#13)
	jr c,l7f30
	sub a
.l7f30
	ld (ix+#13),a
	dec (ix+#18)
	jr nz,l7f3a
	res 5,c
.l7f3b equ $ + 1
.l7f3a
	ld a,#00
	add (ix+#12)
	ld b,a
	ld l,(ix+#0b)
	ld h,(ix+#0c)
	ld a,(hl)
	cp #87
	jr c,l7f52
	ld l,(ix+#09)
	ld h,(ix+#0a)
	ld a,(hl)
.l7f52
	inc hl
	ld (ix+#0b),l
	ld (ix+#0c),h
	add b
	ld hl,l8018
	ld d,#00
	add a
	ld e,a
	add hl,de
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld l,(ix+#1d)
	bit 6,l
	jr z,l7fb4
	ld h,a
	ld b,(ix+#1a)
	sla b
	bit 7,l
	ld a,(ix+#1c)
	jr z,l7f7d
	bit 0,c
	jr nz,l7f9b
.l7f7d
	bit 5,l
	jr nz,l7f8d
	sub (ix+#1b)
	jr nc,l7f98
	set 5,(ix+#1d)
	sub a
	jr l7f98
.l7f8d
	add (ix+#1b)
	cp b
	jr c,l7f98
	res 5,(ix+#1d)
	ld a,b
.l7f98
	ld (ix+#1c),a
.l7f9b
	ex de,hl
	srl b
	sub b
	ld e,a
	ld a,d
	ld d,#00
	jr nc,l7fa6
	dec d
.l7fa6
	add #a0
	jr c,l7fb2
.l7faa
	sla e
	rl d
	add #18
	jr nc,l7faa
.l7fb2
	add hl,de
	ex de,hl
.l7fb4
	ld a,c
	xor #01
	ld (ix+#00),a
	bit 2,c
	jr z,l7fdf
	ld b,(ix+#0e)
	djnz l7fdc
	ld c,(ix+#0d)
	bit 7,c
	jr z,l7fcb
	dec b
.l7fcb
	ld l,(ix+#07)
	ld h,(ix+#08)
	add hl,bc
	ld (ix+#07),l
	ld (ix+#08),h
	add hl,de
	ex de,hl
	jr l7fdf
.l7fdc
	ld (ix+#0e),b
.l7fdf
	cpl
	and #03
.l7fe3 equ $ + 1
	ld a,#38
	jr nz,l7ff0
	ld a,(l7c81)
	xor #08
	ld (l7cce),a
	ld a,#07
.l7ff0
	ld hl,l8005
	xor (hl)
	and (ix+#1f)
	xor (hl)
	ld (hl),a
	ex de,hl
	ld a,(ix+#13)
	ret
.l8005 equ $ + 7
.l8004 equ $ + 6
.l8002 equ $ + 4
.l8000 equ $ + 2
.l7ffe
	db #00,#00,#00,#00,#00,#00,#00,#3f
.l800b equ $ + 5
.l800a equ $ + 4
.l8008 equ $ + 2
.l8007 equ $ + 1
.l8006
	db #0f,#0f,#0f,#00,#00,#00,#00,#00
.l8015 equ $ + 7
.l8013 equ $ + 5
.l8012 equ $ + 4
.l8011 equ $ + 3
.l800f equ $ + 1
	db #00,#00,#00,#00,#3f,#10,#00,#10
.l8017 equ $ + 1
	db #00,#ff
.l8018
	dw #077c,#0708,#06b0,#0640
	dw #05ec,#0594,#0544,#04f8
	dw #04b0,#0470,#042c,#03f0
	dw #03be,#0384,#0358,#0320
	dw #02f6,#02ca,#02a2,#027c
	dw #0258,#0238,#0216,#01f8
	dw #01df,#01c2,#01ac,#0190
	dw #017b,#0165,#0151,#013e
	dw #012c,#011c,#010b,#00fc
	dw #00ef,#00e1,#00d6,#00c8
	dw #00bd,#00b2,#00a8,#009f
	dw #0096,#008e,#0085,#007e
	dw #0077,#0070,#006b,#0064
	dw #005e,#0059,#0054,#004f
	dw #004b,#0047,#0042,#003f
	dw #003b,#0038,#0035,#0032
	dw #002f,#002c,#002a,#0027
	dw #0025,#0023,#0021,#001f
	dw #001d,#001c,#001a,#0019
	dw #0017,#0016,#0015,#0013
	dw #0012,#0011,#0010,#000f
.l80c0
	db #0f,#10,#13,#16,#1a,#1e,#21,#24
	db #27,#2a,#2c,#2e,#30,#32,#34,#00
	db #87,#00,#03,#07,#87,#00,#04,#07
	db #87,#00,#03,#07,#0c,#87,#00,#04
	db #07,#0c,#87,#07,#0c,#0f,#87,#07
	db #0c,#10,#87,#03,#07,#0c,#87,#04
	db #07,#0c,#87,#00,#0c,#87,#00,#04
	db #87,#00,#03,#87,#00,#05,#87,#00
.l8107 equ $ + 7
	db #07,#87,#00,#00,#00,#0c,#87,#10
.l8109 equ $ + 1
.l8108
	db #00,#00
.l8110 equ $ + 6
.l810a
	dw l8110,l8136,l8182,l81c8
	dw l81c8,l81c8,l81c8,l81d7
	dw l81d7,l8216,l8216,l8216
	dw l8216,l8216,l8216,l8216
	dw l8216,l81d7,l81d7,l81d7
.l8136 equ $ + 4
	dw l81d7,#0000,l8236,l8236
	dw l8236,l8236,l8254,l8254
	dw l8254,l8254,l8232,l8273
	dw l8273,l8273,l8273,l8273
	dw l828a,l8273,l828a,l8273
	dw l828a,l8273,l82ba,l8254
	dw l8254,l82a1,l82a1,l8236
	dw l8236,l8236,l8236,l8273
	dw l8273,l8273,l8273,l8273
	dw l8273,l8273,l8273,#0000
.l8182
	dw l82f3,l82f3,l82be,l82be
	dw l82be,l82be,l82be,l82be
	dw l82be,l82be,l82be,l82be
	dw l82be,l82be,l82be,l82be
	dw l82be,l82be,l82be,l82be
	dw l82be,l82be,l82be,l82be
	dw l82be,l82be,l82be,l82be
	dw l82be,l82be,l82be,l82be
	dw l82be,l82be,#0000
.l81c8
	db #bb,#c0,#df,#00,#48,#65,#e3,#0e
.l81d7 equ $ + 7
	db #e1,#1a,#e3,#0e,#f5,#80,#87,#bb
	db #c0,#df,#00,#48,#65,#e7,#0e,#e1
	db #0e,#11,#e3,#0e,#e7,#10,#e1,#10
	db #13,#e3,#10,#e7,#11,#e1,#11,#15
	db #e3,#11,#e7,#13,#e1,#13,#17,#e3
	db #13,#e7,#0e,#e1,#0e,#11,#e3,#0e
	db #e7,#10,#e1,#10,#13,#e3,#10,#e7
	db #11,#e1,#11,#15,#e3,#11,#e7,#13
.l8216 equ $ + 6
	db #e1,#13,#17,#e3,#13,#87,#bb,#88
	db #01,#01,#82,#c0,#de,#00,#48,#65
	db #e1,#1a,#80,#1a,#80,#1a,#18,#17
	db #15,#1f,#15,#17,#18,#1a,#18,#17
.l8236 equ $ + 6
.l8232 equ $ + 2
	db #15,#87,#ff,#80,#80,#87,#bb,#88
	db #01,#01,#82,#db,#22,#41,#25,#8a
	db #e3,#c9,#28,#e1,#80,#e3,#28,#e1
	db #80,#2d,#2b,#2d,#2b,#2d,#2b,#2d
.l8254 equ $ + 4
	db #2b,#28,#26,#87,#bb,#88,#01,#01
	db #82,#de,#22,#81,#25,#8a,#e3,#ce
	db #e3,#2d,#2b,#2a,#28,#e7,#26,#e3
	db #23,#26,#e7,#24,#2b,#e3,#2d,#2b
.l8273 equ $ + 3
	db #29,#2b,#87,#bb,#88,#01,#01,#82
	db #d9,#22,#81,#44,#8a,#e3,#c9,#e3
	db #26,#e1,#21,#1a,#e3,#26,#e1,#21
.l828a equ $ + 2
	db #1a,#87,#bb,#88,#01,#01,#82,#d9
	db #22,#81,#44,#8a,#e3,#c9,#e3,#24
	db #e1,#1f,#18,#e3,#24,#e1,#1f,#18
.l82a1 equ $ + 1
	db #87,#bb,#88,#01,#01,#82,#d9,#22
	db #81,#44,#8a,#e3,#c9,#ef,#85,#2d
	db #ef,#85,#2d,#ef,#85,#2d,#ef,#85
.l82be equ $ + 6
.l82ba equ $ + 2
	db #2d,#87,#e7,#26,#28,#87,#bb,#8b
	db #df,#00,#11,#05,#e3,#8d,#3f,#df
	db #00,#12,#09,#e1,#41,#41,#df,#00
	db #11,#05,#e3,#84,#02,#01,#8d,#27
	db #80,#df,#00,#11,#05,#e3,#8d,#3f
	db #df,#00,#12,#09,#e1,#41,#41,#df
	db #00,#11,#05,#e3,#84,#02,#01,#8d
.l82f3 equ $ + 3
	db #27,#80,#87,#bb,#8b,#df,#00,#11
	db #05,#e3,#41,#41,#41,#41,#41,#41
	db #41,#41,#41,#41,#41,#41,#41,#41
	db #41,#41,#87,#ef,#80,#87
;
.game_name
	db "Nether Earth",0
.game_year
	db "1987",0
.game_publisher
	db "Icon Design Ltd.",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
